package org.jgs1904.util;

import java.util.UUID;

/**
 * UUID工具类
 * @author junki
 * @date 2019年10月17日
 */
public class UUIDUtil {

	private UUIDUtil() {}
	
	public static String getUUID(int length) {
		if (length <= 16) {
			return UUID.randomUUID().toString().replace("-", "").substring(0, length);
		} else {
			StringBuffer sb = new StringBuffer(UUID.randomUUID().toString().replace("-", ""));
			do {
				sb.append(UUID.randomUUID().toString().replace("-", ""));
			} while (sb.length() < length);
			return sb.substring(0, length).toString();
		}
	}
	
}
